//手写防抖
function debounce(fn, await, immediate = false) {
    let timeout;
    let ismeiate = false
    const _debounce = function (...args) {
        if (timeout) clearTimeout(timeout)
        if (immediate && !ismeiate) {
            fn.apply(this, args)
            ismeiate = true
            return
        }
        timeout = setTimeout(() => {
            fn.apply(this, args)
        }, await)
    }

    _debounce.cancle = function () {
        clearTimeout(timeout)
        timeout = null
    }
    return _debounce
}
